package com.lelouch.common;

import com.lelouch.bean.SysUser;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;

/**
 * Request的ThreadLocal
 *
 * @author lcy
 * @create 2018-06-20 17:42
 */
@Slf4j
public class RequestHolder {

    public static final ThreadLocal<SysUser> user = new ThreadLocal<SysUser>();

    public static final ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();

    public static void addUser(SysUser sysUser){
        user.set(sysUser);
    }

    public static void addRequest(HttpServletRequest httpServletRequest){
        request.set(httpServletRequest);
    }

    public static SysUser getUser(){
        return user.get();
    }

    public static HttpServletRequest getRequest(){
        return request.get();
    }

    public static void remove(){
        user.remove();
        request.remove();
    }
}
